/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.dao.hibernate;

import com.minierp.dao.BankAccountBalanceDao;
import com.minierp.dao.hibernate.BaseDaoImpl;
import com.minierp.model.BankAccountBalance;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

public class BankAccountBalanceDaoImpl extends BaseDaoImpl
		implements
			BankAccountBalanceDao {
	public List getList(long bankAccountId, Date startDate) {
		String sql = "from com.minierp.model.BankAccountBalance as obj where obj.bankAccountId = "
				+ bankAccountId
				+ " and obj.balanceDate>:balanceDate"
				+ " order by obj.balanceDate";
		Session sess = null;

		List arg7;
		try {
			sess = this.getSession();
			Query q = sess.createQuery(sql);
			q.setDate("balanceDate", startDate);
			arg7 = q.list();
		} finally {
			if (sess != null) {
				this.releaseSession(sess);
			}

		}

		return arg7;
	}

	public BankAccountBalance getPreviousBalance(long bankAccountId,
			Date startDate) {
		String sql = "from com.minierp.model.BankAccountBalance as obj where obj.bankAccountId = "
				+ bankAccountId
				+ " and obj.balanceDate<=:balanceDate"
				+ " order by obj.balanceDate desc";
		Session sess = null;

		try {
			sess = this.getSession();
			Query q = sess.createQuery(sql);
			q.setDate("balanceDate", startDate);
			q.setFirstResult(0);
			q.setMaxResults(1);
			List list = q.list();
			if (!list.isEmpty()) {
				BankAccountBalance arg8 = (BankAccountBalance) list.get(0);
				return arg8;
			}
		} finally {
			if (sess != null) {
				this.releaseSession(sess);
			}

		}

		return null;
	}
}